﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Test1
{
    public partial class Form15_03 : Form
    {
        public Form15_03()
        {
            InitializeComponent();
            CheckForIllegalCrossThreadCalls = false;
        }

        private void Form15_03_Load(object sender, EventArgs e)
        {
            t1 = new Thread(new ThreadStart(Pro1));
            t1.Start();
            t2 = new Thread(new ThreadStart(Pro2));
            t2.Start();
        }

        Thread t1, t2;
        void Pro1()
        {
            int count = 0;
            while (true)
            {
                progressBar1.PerformStep();
                count += progressBar1.Step;
                Thread.Sleep(100);
                if (count == 20)
                {
                    t2.Join();
                }
            }
        }
        void Pro2()
        {
            int count = 0;
            while (true)
            {
                progressBar2.PerformStep();
                count += progressBar1.Step;
                Thread.Sleep(100);
                if (count == 100)
                {
                    break;
                }
            }
        }
    }
}
